package com.granada.service.base;

import com.granada.behaviour.base.PermissionBehavior;
import com.granada.behaviour.interfaces.UserAuthBehavior;
import com.granada.entity.SysUser;
import com.granada.behaviour.base.RoleBehavior;
import com.granada.vo.req.LoginReqVO;
import com.granada.vo.resp.LoginRespVO;
import com.granada.vo.resp.UserLoginAppRespVO;

import java.util.List;

public abstract class UserAuthService<T extends SysUser> implements UserAuthBehavior {
    protected com.granada.behaviour.base.UserAuthBehavior userAuthBehavior;
    protected PermissionBehavior permissionBehavior;
    protected RoleBehavior roleBehavior;

    public UserAuthService(
            com.granada.behaviour.base.UserAuthBehavior userAuthBehavior,
            PermissionBehavior permissionBehavior,
            RoleBehavior roleBehavior
    ) {
        this.userAuthBehavior = userAuthBehavior;
        this.permissionBehavior = permissionBehavior;
        this.roleBehavior = roleBehavior;
    }
    public abstract String refreshToken(String refreshToken, String accessToken) throws Exception;

    @Override
    public List<UserLoginAppRespVO> getUserLoginInfo(Long userId) throws Exception {
        return this.userAuthBehavior.getUserLoginInfo(userId);
    }


    @Override
    public abstract LoginRespVO login(LoginReqVO vo) throws Exception;

    @Override
    public Boolean logging(LoginReqVO vo) throws Exception {
        return this.userAuthBehavior.logging(vo);
    }

    @Override
    public void logout(String accessToken, String refreshToken) throws Exception {
        this.userAuthBehavior.logout(accessToken, refreshToken);
    }
}
